Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement remote feature flag controller #12427

Open
wants to merge 50 commits into
base: main
Choose a base branch
from

Conversation

joaoloureirop
Copy link
Contributor

@joaoloureirop joaoloureirop commented Nov 26, 2024

Description

Introduction of @metamask/remote-feature-flag-controller library.

Remote feature flag controller manages data flow, retry policy, and cache expiry.
The controller consumer manages default values, data persistency, and data distribution.

See ADR for a in-depth description

Technical decisions

Controller init on Engine.ts with feature flags fetching only on cold app starts.

@metamask/remote-feature-flag-controller is only asked to fetch feature flags after its init in Engine.ts. Ensures feature flags are only fetched on cold app starts.

Fallback values

Default values are used when remote feature flags are undefined.
The fallback mechanism is implemented by each feature flag selector app/selectors/featureFlagsController/<featureFlagName>

In this PR we include minimumAppVersion selector, which manages the LD feature flag mobile-minimum-versions

One selector per each feature flag

LD feature flags can be boolean, number, strings on JSON objects.
We've decided to have each feature flag with its own selector

A feature flag selector contains:

  • state selectors for each feature flag value.
  • business logic
  • defaults for when feature flags values are undefined.
  • TS types.
  • unit tests and mocked data.

This architecture offers a clear separation between each feature flag and the logic behind it, allowing easier manipulation.
Code owners are assigned to each feature flag.

Related issues

Fixes: https://github.com/MetaMask/mobile-planning/issues/2054
Fixes: https://github.com/MetaMask/mobile-planning/issues/1975

Manual testing steps

  1. Go to this page...

Screenshots/Recordings

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@joaoloureirop joaoloureirop self-assigned this Nov 26, 2024
@joaoloureirop joaoloureirop changed the title feat: feature-flag-controller feat: implement remote feature flag controller Nov 26, 2024
app/core/Engine.ts Outdated Show resolved Hide resolved
metro.config.js Outdated Show resolved Hide resolved
metro.config.js Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
yarn.lock Outdated Show resolved Hide resolved
Copy link

socket-security bot commented Nov 29, 2024

New dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@metamask/[email protected] None 0 115 kB metamaskbot

View full report↗︎

@codecov-commenter
Copy link

codecov-commenter commented Nov 29, 2024

Codecov Report

Attention: Patch coverage is 79.62963% with 11 lines in your changes missing coverage. Please review.

Project coverage is 57.09%. Comparing base (22a4989) to head (9cd1bf0).
Report is 73 commits behind head on main.

Files with missing lines Patch % Lines
...e/controllers/RemoteFeatureFlagController/utils.ts 55.00% 6 Missing and 3 partials ⚠️
...nents/hooks/MinimumVersions/useMinimumVersions.tsx 50.00% 0 Missing and 1 partial ⚠️
app/selectors/settings.ts 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12427      +/-   ##
==========================================
+ Coverage   56.41%   57.09%   +0.67%     
==========================================
  Files        1797     1823      +26     
  Lines       40586    40902     +316     
  Branches     5097     5171      +74     
==========================================
+ Hits        22896    23352     +456     
+ Misses      16134    15965     -169     
- Partials     1556     1585      +29     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

joaoloureirop and others added 6 commits November 29, 2024 16:42
## **Description**

Add unit tests to feature flags controller and useMinimumVersions unit
tests updated
## **Related issues**

Fixes:

## **Manual testing steps**

1. Go to this page...
2.
3.

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [ ] I’ve followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
@joaoloureirop joaoloureirop added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Nov 29, 2024
Copy link
Contributor

github-actions bot commented Nov 29, 2024

https://bitrise.io/ Bitrise

✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅

Commit hash: 9cd1bf0
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/18207d2d-9854-41b3-916d-d079e3ca8ba8

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

Copy link

sonarcloud bot commented Nov 29, 2024

@joaoloureirop joaoloureirop added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) needs-qa Any New Features that needs a full manual QA prior to being added to a release. Run Smoke E2E Triggers smoke e2e on Bitrise team-mobile-platform
Projects
Status: Needs dev review
Development

Successfully merging this pull request may close these issues.

9 participants